// Test using Boost Graph library
// Just generate a graph representing K_8

#include "nauty.h"
#include <iostream>
#include <utility>
#include <algorithm>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>

using namespace boost;
using namespace std;

// Functor for vertices from a graph of generic type GraphT
template <class GraphT> struct exercise_vertex
{
   // Functor constructor - hold onto g_
   // g_ is the functor's "state between calls"
   exercise_vertex(GraphT& g_) : g(g_) {}

   typedef typename graph_traits<GraphT>::vertex_descriptor Vertex;

   // object acts as a function by defining operator()
   void operator()(const Vertex& v) const
   {
      typedef graph_traits<GraphT> GraphTraits;
      typename property_map<GraphT, vertex_index_t>::type index = get(vertex_index,g);

      cout << "VERTEX " << v << endl;
      cout << "adjacent vertices: ";
      typename graph_traits<GraphT>::adjacency_iterator ai, ai_end;
      for (tie(ai,ai_end) = adjacent_vertices(v,g); ai != ai_end; ++ai)
      {
         cout << index[*ai] << " ";
      }
      cout << endl;
   }

   GraphT& g;
};

int main(int argc, char* argv[])
{
   if (argc != 2)
   {
      cout << "Enter number of vertices" << endl;
      exit(1);
   }

   int num_verts = atoi(argv[1]);

   // Represent graph as an adjacency list
   typedef adjacency_list<vecS, vecS, undirectedS> Graph;

   // Represent an edge as a vertex pair
   typedef pair<int,int> Edge;

   // create a fully connected graph
   Graph g(num_verts);

   for (int i=0; i<num_verts; i++)
   {
      for (int j=i+1; j<num_verts; j++)
      {
         add_edge(i,j,g);
      } 
   }

   // Try enumerating vertex data
   // Get vertex iterator specific to this graph
   typedef graph_traits<Graph>::vertex_iterator vertex_iter;
   pair<vertex_iter,vertex_iter> ver_iters;
   // Get graph property map to access mapping of indices
   typedef property_map<Graph, vertex_index_t>::type IndexMap;
   IndexMap index = get(vertex_index,g);

   // Find a one factor
   Graph oneFactor(num_verts);

   // call to vertices() returns a vertex_iterator pair used to iterate
   ver_iters = vertices(g);
   vertex_iter v = ver_iters.first;
   while (v != ver_iters.second)
   {
      int v1 = *v;
      cout << index[*v] << " ";
      v++;
   }
   cout << endl;

   // Try enumerating edge data
   graph_traits<Graph>::edge_iterator ei, ei_end;
   // tie function extracts values from a std::pair
   for (tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
   {
      cout << "(" << index[source(*ei,g)] << "," << index[target(*ei,g)] << ") ";
   }
   cout << endl;

   // Use a functor to access vertex description data
   for_each(vertices(g).first,vertices(g).second,exercise_vertex<Graph>(g));

   return 0;
}

What a beautiful piece of code! I hope I am not defiling it now
